package czh.cocoa.graphics;

import czh.cocoa.foundation.NSObject;
import android.graphics.Canvas;
import android.graphics.Picture;

public class CGPicture extends NSObject implements CGDrawable {

	private Picture mPicture;
	
	private CGSize mSize;
	
	public CGPicture(CGSize size) {
		mPicture = new Picture();
		mSize = size;  
	}
	
	public CGContext beginContext() {  
		Canvas canvas = mPicture.beginRecording((int)mSize.width, (int)mSize.height);
		return new CGContext(canvas); 
	}
	
	public void endContext() {
		mPicture.endRecording();
	}

	@Override
	public void draw(Canvas canvas) {  
		canvas.drawPicture(mPicture);   
	}

	@Override
	public CGSize size() {
		return new CGSize(mSize);
	}
	
}
